<?php

use core\tools\Utils;

$vars['helper']->insertMessage();

$reports = $vars['reports'];

$userId=$vars['userId'];

$vars['helper']->addCssFile('report_loop.css');
// to remove the container css class
$vars['helper']->setContainerClass('');


?>

<div id="link-back">
	<a class="button" 
		href="<?php echo $vars['helper']->createHref('Home')?>">
			<?php echo __('Home'); ?>
	</a>
&nbsp;
	<a class="button" 
	href="<?php $vars['helper']->insertHrefWithNonce('displayProfile', 'Profile', 'display', array( 'userId' => $userId )); ?>">
		<?php echo __('Profile'); ?>
	</a>
&nbsp;
<h4> <?php echo __('Manage reports'); ?></h4>
</div>

<?php if($reports): // forum loop ?>
	<div class="rounded-box">
		<div class="navigation"></div>
		<table class="forum-loop">
			<thead>
				<tr class="background_primary">
					<th id="title"><?php echo __('Reports');?></th>
					<th id="numberOfReport"><?php echo __('Number of report');?></th>
					<th id="lastDateOfReport"><?php echo __('Last date of report');?></th>					
					<th id="treatment"><?php echo __('Treated?');?></th>
					<th id="deletion"><?php echo __('Delete');?></th>
				</tr>
			</thead>
			<tbody>
			<?php
					$size = count($reports);
					$removeDescription = __('To delete the reports');
					for($i = 0 ; $i < $size ; $i++):
						$report = $reports[$i];
						$title = $report->title;
						$description = $report->complete;
						$link = $report->link;						
						$deleteLink = $report->deleteLink;						
						$reportCount = $report->count;
						$date = $report->date;
						$reportTreated = $report->treated;
				?>
					<tr>
						<td class="title">
							<a class="topic-title" href="<?php echo $link ?>"
								title="<?php echo $description; ?>"><?php echo $title; ?></a></td>
						<td class="numberOfReport">
							<?php echo $reportCount; ?>
						</td>
						<td class="lastDateOfReport">
							<?php echo Utils::getDataSince($date); ?>
						</td>
						<td class="treatment">
							<?php echo $reportTreated ? 'true':'false'; ?>
						</td>
						<td class="deletion">
							<a href="<?php echo $deleteLink; ?>"
								title="<?php echo $removeDescription; ?>"><?php echo '[<b>X</b>]'; ?></a>
						</td>
					</tr>
				<?php endfor ?>
			</tbody>
		</table>
		<div class="navigation"></div>
	</div>
	
<?php else: // no topics in this forum ?>
	<?php $vars['helper']->addCssFile('messages.css'); ?>
	<div class="rounded-box pagged">
		<div class="message info centered"><?php echo __('No report for the moment');?></div>
	</div>
<?php endif; ?>



